package com.example.filter;

import com.zomato.photofilters.imageprocessors.Filter;
import com.zomato.photofilters.imageprocessors.SubFilter;
import com.zomato.photofilters.imageprocessors.subfilters.BrightnessSubFilter;
import com.zomato.photofilters.imageprocessors.subfilters.ContrastSubFilter;
import com.zomato.photofilters.imageprocessors.subfilters.ToneCurveSubFilter;
import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import org.junit.Assert;
import org.junit.Test;

import java.util.List;

import static org.junit.Assert.assertEquals;

public class ExampleOhosTest {
    @Test
    public void testBundleName() {
        final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
        assertEquals("com.example.ohosphotofilters", actualBundleName);
    }

    @Test
    public void testSetAndGetTag() {
        String expectedTag = "toneCurveSubFilter";
        ToneCurveSubFilter toneCurveSubFilter = new ToneCurveSubFilter(null, null, null, null);
        toneCurveSubFilter.setTag("toneCurveSubFilter");
        String actualTag = toneCurveSubFilter.getTag();
        Assert.assertEquals(expectedTag, actualTag);
    }

    @Test
    public void testClearSubFilters() {
        Filter filter = new Filter();
        filter.addSubFilter(new BrightnessSubFilter(30));
        filter.addSubFilter(new ContrastSubFilter(1f));
        filter.clearSubFilters();
        Assert.assertTrue(filter.getSubFilters().isEmpty());
    }

    @Test
    public void testRemoveAndGetSubFilterWithTag() {
        Filter filter = new Filter();
        ToneCurveSubFilter toneCurveSubFilter = new ToneCurveSubFilter(null, null, null, null);
        BrightnessSubFilter brightnessSubFilter = new BrightnessSubFilter(30);
        toneCurveSubFilter.setTag("toneCurveSubFilter");
        brightnessSubFilter.setTag("brightnessSubFilter");
        filter.addSubFilter(toneCurveSubFilter);
        filter.addSubFilter(brightnessSubFilter);
        filter.removeSubFilterWithTag("toneCurveSubFilter");
        List<SubFilter> subFilters = filter.getSubFilters();
        boolean contains = subFilters.contains(toneCurveSubFilter);
        SubFilter actualBright = filter.getSubFilterByTag("brightnessSubFilter");
        Assert.assertFalse(contains);
        Assert.assertEquals(brightnessSubFilter, actualBright);
    }
}